﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using TileEngine.items.tiles.material;
using TileEngine.items;

namespace TileEngine.tiles.material
{
    class Crome : DefaultTile
    {
        public Crome(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public Crome()
        {
        }
        override public void draw(SpriteBatch spriteBatch, Point destinationPoint,Color tint)
        {
            int frame = 0;
            if (Global.currentWorld.tiles[x, y - 1].tile.GetType() != typeof(Empty))
                frame += 8;
            if (Global.currentWorld.tiles[x + 1, y].tile.GetType() != typeof(Empty))
                frame += 4;
            if (Global.currentWorld.tiles[x, y + 1].tile.GetType() != typeof(Empty))
                frame += 2;
            if (Global.currentWorld.tiles[x - 1, y].tile.GetType() != typeof(Empty))
                frame += 1;

            spriteBatch.Draw(Textures.crome, new Rectangle(destinationPoint.X, destinationPoint.Y, 20, 20), new Rectangle((frame % 4) * 20, ((int)(frame / 4)) * 20, 20, 20), tint);
            //spriteBatch.DrawString(Textures.font8, x.ToString() , new Vector2(destinationRectangle.X + 1, destinationRectangle.Y), Color.Black);
            //spriteBatch.DrawString(Textures.font8, y.ToString(), new Vector2(destinationRectangle.X + 1, destinationRectangle.Y + 8), Color.Black);
        }
        override public bool breakTile()
        {
            Global.currentWorld.tiles[x, y].tile = new Empty(x,y);
            Global.currentWorld.items.Add(new CromeItem(new Vector2(x*Global.tileSize.X,y*Global.tileSize.Y)));
            return true;
        }
        override public Type getItemType()
        {
            return typeof(CromeItem);
        }
        public override double getLightAbsorption()
        {
            return 0.5;
        }
    }
}
